if(!dojo._hasResource["opm.widgets.component.Security"]){
dojo._hasResource["opm.widgets.component.Security"] = true;
dojo.provide("opm.widgets.component.Security");
dojo.require("dijit._Widget");
dojo.require("opm.widgets.Ajax");
dojo.declare("opm.widgets.component.Security",dijit._Widget,
{
   contentId:"",
   defaultURL:"",
   _GENERIC_PAGE:"Security.genericPage",
   _SECURITY_SEARCH_FORM:"Security.search",
   _SECURITY_EDIT_FORM:"Security.edit",

   constructor:function(args){
      this.contentId = args.contentId;
   },
   showSecuritiesForm:function(ajaxUrl,callBackFunction){
      var dataPage = {
         ajaxCallUrl: ajaxUrl,
         ajaxCallType:'callXhrGetJson',
         contentId:this.contentId,
         widgetId: this._GENERIC_PAGE,
         currentFormWidgetId:this._SECURITY_SEARCH_FORM,
         postCreated:function(){
            var forms = this.existedforms;
            var searchForm=forms[0];
            var resultForm=forms[1];
            resultForm.connectEvent("btnCancelClick",function(d){
               callBackFunction();
            });
            searchForm.connectEvent("btnAddClick",function(d){
               searchForm.callSaveForm({handleSuccess:function(data){
                  resultForm.getWidget("JSONSecurityIds","arrow").setLeftData(data);
               }});
            });
            resultForm.connectEvent("btnAddClick",function(d){
               resultForm.callSaveProperties(["JSONSecurityIds"],{handleSuccess:function(data){
                  callBackFunction();
               }});
            });
         }
      };
      var genericPage = OPM.genericPageWidget(dataPage);
      genericPage.createPage();
   },
   showEditForm:function(ajaxUrl,callBackFunction){
      var dataform = {
         ajaxCallUrl: ajaxUrl, 
         ajaxCallType:'callXhrGetJson',
         contentId: this.contentId,
         widgetId: this._SECURITY_EDIT_FORM
      };
      var genericForm = OPM.genericFormWidget(dataform);
      genericForm.connectEvent("btnCancelClick", function(data){
         callBackFunction.cancel();
      });
      genericForm.connectEvent("btnDeleteClick", function(data){
         var genericFormDialog = null;
         var deleteUrl = genericForm.getAtt("deleteUrl");
         var handleClickBtnYesFunction = {
            deleteUrl: deleteUrl,
            callBackFunction: function(){
                genericFormDialog.callPostText({
                  ajaxUrl: this.deleteUrl,
                  handleSuccess: function(data){
                     genericFormDialog.close();
                     callBackFunction.succ();
                  }
               });
            }
         };
         var dataForm = {title:genericForm.getAtt("deleteTitle"),content:genericForm.getAtt("deleteContent"),handleClickBtnYes:handleClickBtnYesFunction};
         genericFormDialog=OPM.genericFormDialogWiget(dataForm, 'center');
         genericFormDialog.showDialog();
      });
      genericForm.connectEvent("btnAddClick", function(data){
         genericForm.callSaveProperties(["JSONPermissions"],{handleSuccess:function(){
            callBackFunction.succ();
         }});
      });
      genericForm.createForm();
   }
});}
